/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Mapper;

import com.sun.xml.rpc.processor.modeler.j2ee.xml.string;
import java.util.*;
import java.sql.*;

/**
 *
 * @author Quang Thao
 */
public class Book_TypeMapper extends DBMapper {

    public Book_TypeMapper() throws SQLException, Exception {
        super();
    }

    public List GetAll() throws Exception {
        List list = new ArrayList<Bean.Book_TypeBean>();
        PreparedStatement stmt = getConnection().prepareStatement("SELECT * FROM Book_Type");
        ResultSet rs = stmt.executeQuery();
        if (rs != null) {
            while (rs.next()) {
                Bean.Book_TypeBean bt = new Bean.Book_TypeBean();
                bt.setID(rs.getString(1));
                bt.setName(rs.getString(2));
                bt.setStatus(rs.getString(3));
                list.add(bt);
            }
        }
        stmt.close();
        return list;
    }

    public Bean.Book_TypeBean GetInfo(String id) throws Exception {
        Bean.Book_TypeBean bt = new Bean.Book_TypeBean();
        PreparedStatement stmt = getConnection().prepareStatement("SELECT * FROM Book_Type WHERE ID='" + id + "'");
        ResultSet rs = stmt.executeQuery();
        if (rs != null && rs.next()) {
            bt.setID(rs.getString(1));
            bt.setName(rs.getString(2));
            bt.setStatus(rs.getString(3));
        }
        stmt.close();
        return bt;
    }
}
